<template>
	<view>
		<!--  -->
		<block v-if="messageList.length">
			<!-- 医生列表 -->
			<div class="list" @click="go(val)" v-for="(val,i) in messageList" :key="i">
				<div class="item m-10 p-20" style="background-color: white;border-radius: 20rpx;">
					
					<div class="flexflex  " style="align-content: center;justify-content: space-between;" >
						<div class="name size_14 font-b">{{val.uname}}</div>
						<!-- subjectname -->
						<!-- 						<div class=" size_10 mx-4 text-ellipsis flex " style="width: 380rpx;align-content: center">
							
						</div> -->
						{{val.subjectname}}
						<!--  -->
						<view class="size_12  uni-text-gray" v-if="val.appStatus == '0'">{{'待接诊'}}</view>
						<view class="size_12  text-blue" v-if="val.appStatus == '1'">{{'问诊中'}}</view>
						<view class="size_12 text-yellow" v-if="val.appStatus == '3'">{{'已完成'}}</view>
					</div>
					<u-gap height="8"></u-gap>
					<!-- <div class="word text-ellipsis size_16">{{val.diseaseDescription}}</div> -->
					<u-text :text="val.diseaseDescription" line-height="20" lines="2"></u-text>
					<u-gap height="10"></u-gap>
					<div class="time size_10 uni-text-gray" style="color: #1D1D1D;">{{ timeOut(val.createTime)}}</div>
				</div>
			</div>


			<!-- 			<view class="margin" @click="go(val)" v-for="(val,i) in messageList" :key="i"  >
				<view class="item1  flexflex u-border-bottom my-10">
					<view class="mr-10 ">
						<u-avatar :src="val.uname  || '/static/img/finddoctor/02-yishen.png' "></u-avatar>
					</view>
					<view class="" style="width: 100%;">
						<u-row :gutter='5'>
							<u-col span="3">
								<view class="demo-layout bg-purple-light">
									<view class="size_16 font_b">{{val.uname }}</view>
								</view>
							</u-col>
							<u-col span="6">
								<view class="demo-layout bg-purple">
									<view class="size_14">{{val.deptname }}</view>
								</view>
								<view class="demo-layout bg-purple">
									<view class="size_14">{{val.diagnosissubjectname }}</view>
								</view>
								<view class="demo-layout bg-purple">
									<view class="size_14">{{val.subjectname }}</view>
								</view>
							</u-col>
							<u-col span="3">
								<view class="demo-layout bg-purple-light">
									<view class="size_14  uni-text-gray" v-if="val.applyStatus == '0'">{{'待接诊'}}</view>
									<view class="size_14  text-blue" v-if="val.applyStatus == '1'">{{'问诊中'}}</view>
									<view class="size_14 text-yellow" v-if="val.applyStatus == '3'">{{'已完成'}}</view>
								</view>
							</u-col>
						</u-row>
						<u-row class="mt8 ms10  ">
							<u-col span="8">
								<view class="demo-layout bg-purple-light">
									<view class="size_14 ">{{val.ucompname }}</view>
								</view>
							</u-col>
							<u-col span="4">
								<view class="demo-layout bg-purple">
									<view class="size_14">{{val.udepartmentname }}</view>
								</view>
							</u-col>
						</u-row>
						<u-row>
							<u-col>
								<view class="demo-layout bg-purple mb-10 ">
									<text class="u-line-1 size_12 color_84">{{val.introduction}}</text>
								</view>
							</u-col>
						</u-row>
		
					</view>
				</view>
			</view> -->
			
		</block>
		<!--  -->
		<u-empty v-else mode="data">
		</u-empty>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				messageList: [],
				avatarList: [{
					url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png'
				}, {
					url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png'
				}, {
					url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png'
				}]
			};
		},
		onLoad() {
			// this.getDoctorPage()
			this.getChatList()
		},
		methods: {
			
				
			timeOut(timeString){
				function convertTimeFormat(timeString) {
				    const date = new Date(timeString);
				    const year = date.getFullYear();
				    const month = date.getMonth() + 1;
				    const day = date.getDate();
				    const hour = date.getHours();
				    const minute = date.getMinutes();
				    const second = date.getSeconds();
				    const period = (hour < 12) ? '上午' : '下午';
				    const hour12 = (hour > 12) ? hour - 12 : hour;
				
				    const formattedTime = `${year}年${month}月${day}日${period}${hour12}点${minute}分${second}秒`;
				    return formattedTime;
				}
				return convertTimeFormat(timeString)
			},
			
			
			go(val) {
				this.$pub.go('/pages_message/chathos/chathos?data=' + encodeURIComponent(JSON.stringify(val)));
			},
			async getChatList() {
				let userId = uni.getStorageSync('userInfo').userid
				console.log(userId, "userId");
				let re = await this.$API.messageApi.getChatList(userId)
				this.messageList = re
			},

			// async getDoctorPage() {
			// 	let re = await this.$API.messageApi.myDoctor()
			// 	this.messageList = re
			// },
		}
	}
</script>

<style>
	page{
		background-color: #F2F2F2;
	}
</style>

<style lang="scss" scoped>
	/* 更改tag切换颜色 */
	::v-deep .u-tag--primary {
		background-color: #7976E9;
		border-color: #7976E9;

	}

	::v-deep .u-tag--primary span {
		color: #FFFFFF;
	}

	.u-page__tag-item {
		// margin-right: 40rpx;
	}
	page{
		background-color: #FFFFFF;
	}
</style>